<?php

use yii\helpers\Html;
use kartik\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel backend\modules\logs\models\CreditOrderLogSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Credit Order Logs';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="credit-order-log-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            [
                'class' => \kartik\grid\ExpandRowColumn::className(),
                'width' => '50px',
                'value' => function ($model, $key, $index, $column) {
                    return \kartik\grid\GridView::ROW_COLLAPSED;
                },
                'detail' => function ($model, $key, $index, $column) {
                    return Yii::$app->controller->renderPartial('view', ['model'=>$model, 'id'=>$key]);
                },
                'headerOptions' => ['class' => 'kartik-sheet-style'],
                'expandOneOnly' => true,
                'pageSummary'=>'总计',//可以是字符串，当为true时，自动合计
            ],
            'credit_order_id',
            [
                'attribute'=>'post_idno',
                'value' => function($model, $key, $index, $column){
                    $post_data = unserialize($model->post_data);
                    return $post_data['idno'];
                }
            ],
            [
                'attribute'=>'credit_idno',
                'value' => function($model, $key, $index, $column){
                    $credit_order_data = unserialize($model->credit_order_data);
                    return $credit_order_data['idno'];
                }
            ],
            'time:datetime',
            'post_data:ntext',
            'send_return_msg',
            'credit_order_data:ntext',
            'old_status',
            'new_status',
            'api_return_code',
            'api_return_msg',
            'serial_number',
        ],
    ]); ?>
</div>
